<template>
    <div>
        <!-- tab-top-webview-main -->
		<!-- 滑动导航 -->
		<div class="mui-content">
			<div id="slider" class="mui-slider">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<a v-for="(item,i) in cates" :key="item.id" @tap="getNavListTp(item.id)" :class="['mui-control-item',{'mui-active':i==0}]" data-wid="tab-top-subpage-6.html">
							{{item.title}}
						</a>
					</div>
				</div>
			</div>
		</div>
		<!-- 图片内容区 -->
		<ul class="photo-list">
			<router-link v-for="item in list" :key="item.id" :to="'/home/photoslist/photosInfo/'+item.id" tag="li">
				<img v-lazy="item.img_url">
				<div class="info">
					<h4 class="info-title">{{item.title}}</h4>
					<div class="info-body">{{item.zhaiyao}}</div>
				</div>
			</router-link>
		</ul>
    </div>
</template>

<script>
//导入以下mui，需要移除严格格式 ，
//npm install babel-plugin-transform-remove-strict-mode -D
//.babelrc中添加以下信息
//"transform-remove-strict-mode"
import mui from "../../lib/mui/js/mui.js";
import { Toast } from 'mint-ui';
export default {
	data() {
		return {
			list:[],
			cates:[],
			flag:0
		}
	},
	created() {
		this.getNavList();
		this.getNavListTp(0);
	},
	methods: {
		getNavList(){
			this.$http.get("../../localdata/photocates.json").then(result=>{
				if (result.body) {
					this.cates=result.body;
				} else {
					Toast("加载评论失败！！！");
				}
				
			})
		},
		getNavListTp(id){
			this.$http.get("../../localdata/photos.json").then(result=>{
				if (result.body) {
					if(id==0){
						this.list=result.body;
						// console.log(this.list)
					}else{
						this.list=result.body.filter(item=>{
							if (item.cateid==id) {
								return item;
							}
						})
					}
				} else {
					Toast("加载图片失败！！！");
				}
				
			})
		},
	},
	mounted() {
		mui('.mui-scroll-wrapper').scroll({
			deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
		});
	},
}
</script>

<style lang="scss" scoped>
/* 解决警告加以下样式[Intervention] Unable to preventDefault inside passive event listener due to target being treated as passive. See <URL> */
	/* 是chrom 为了提高滑动流畅度 */
	* { touch-action: pan-y; }
	.photo-list{
		list-style: none;
		margin: 0;
		padding: 10px;
		padding-bottom: 0;

		li{
			background-color: #ccc;
			text-align: center;
			margin-bottom: 10px;
			box-shadow: 0 0 9px #999;
			position: relative;
			
			img{
				display: block;
				width: 100%;
				height: 300px;
			}

			image[lazy=loading] {
				width: 40px;
				height: 300px;
				margin: auto;
			}

			.info {
				width: 100%;
				color: white;
				text-align: left;
				position: absolute;
				bottom: 0;
				background-color: rgba(0, 0, 0, 0.4);
				max-height: 84px;
				.info-title {
					font-size: 14px;
				}
				.info-body {
					font-size: 13px;
				}
			}
		}

	}
</style>